<template>
  <el-form
    ref="ruleForm"
    :model="ruleForm"
    :rules="rules"
    label-width="120px"
    size="small"
  >
    <el-form-item label="账户名称" prop="accountName">
      <el-input v-model.trim="ruleForm.accountName" placeholder="请输入账户名称"></el-input>
    </el-form-item>

    <el-form-item label="账户账号" prop="accountNumber">
      <el-input v-model.trim="ruleForm.accountNumber" placeholder="请输入账户账号"></el-input>
    </el-form-item>
    <el-form-item label="账户所属角色" prop="roleIdList">
      <el-select v-model="ruleForm.roleIdList" placeholder="请选择所属角色" class="block" multiple>
        <el-option v-for="(i, k) in roles" :label="i.label" :value="i.value" :key="k"></el-option>
      </el-select>
    </el-form-item>
  </el-form>
</template>

<script>
/* Mixins
------------------------------- */
import { Form } from '@/mixins'

/* Api
------------------------------- */

/* Model
------------------------------- */
import { accountModel } from '../model'
export default {
  mixins: [Form('ruleForm', accountModel)],
  props: {
    roles: {
      type: Array,
      default () {
        return []
      }
    }
  },
  data () {
    return {
      key: 1,
      ruleForm: Object.assign({}, accountModel),
      rules: {
        accountName: [
          {
            required: true,
            message: this.$t('required', { field: '账户名称' })
          }
        ],
        accountNumber: [
          {
            required: true,
            message: this.$t('required', { field: '账户账号' })
          }
        ]
      }
    }
  },
  methods: {
    handleError () {
      return false
    }
  },
  mounted () {
    this.watchSelect('accountType', 'accountTypeValue', this.$attrs.types)
  },
  computed: {}
}
</script>
